<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/layui.css" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/view.css" />
    <title>管理后台</title>
</head>
<body class="layui-view-body">
<div class="layui-content">
    <div class="layui-page-header">
        <div class="pagewrap">
            <span class="layui-breadcrumb"> </span>
            <h2 class="title">课程信息</h2>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-card">
            <div class="layui-card-body">
                <div class="form-box">
                    <form class="layui-form" lay-filter="test" action="${pageContext.request.contextPath}/lesson/findLesson" method="post">
                        <div class="layui-form layui-form-item">
                            <div class="layui-inline">
                                <div class="layui-form-mid">课程编号:</div>
                                <div class="layui-input-inline" style="width: 200px;margin-right: 20px">
                                    <input type="text" name="lno" autocomplete="off" class="layui-input" placeholder="请输入课程编号"/>
                                </div>
                                <div class="layui-form-mid">课程名:</div>
                                <div class="layui-input-inline" style="width: 200px;margin-right: 20px">
                                    <input type="text" name="name" autocomplete="off" class="layui-input" placeholder="请输入课程名"/>
                                </div>

                                <input type="submit" value="查询" class="layui-btn layui-btn-blue" style="margin-left: 50px">
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                                <span style="color: red;margin-left: 20px">${error}</span>
                            </div>
                        </div>
                    </form>

                    <a href="${pageContext.request.contextPath}/lesson/toAddLessonPage" class="layui-btn layui-btn-blue">
                        <i class="layui-icon">&#xe654;</i>新增
                    </a>

                    <table class="layui-table">
                        <colgroup>
                            <col width="150" />
                            <col width="200" />
                            <col />
                        </colgroup>
                        <thead>
                        <tr>
                            <th class="mywidth2">课程号</th>
                            <th class="mywidth2">课程名称</th>
                            <th class="mywidth2">先修课程</th>
                            <th class="mywidth2">学分</th>
                            <th class="mywidth2">操作</th>
                        </tr>
                        </thead>

                        <tbody>
                        <c:forEach var="lesson" items="${lessonList}">
                            <tr>
                                <td>${lesson.lno}</td>
                                <td>${lesson.name}</td>
                                <td>${lesson.plName}</td>
                                <td>${lesson.credit}</td>
                                <td>
                                    <a href="${pageContext.request.contextPath}/lesson/toUpdateLessonPage/${lesson.lno}" class="layui-btn layui-btn-sm">修改</a>
                                    &nbsp;|&nbsp;<a href="${pageContext.request.contextPath}/lesson/deleteLesson/${lesson.lno}" onclick="if(confirm('确认删除吗？')===false)return false;" class="layui-btn layui-btn-danger layui-btn-sm">删除</a>
                                </td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>

                    <div class="layui-box layui-laypage layui-laypage-default" id="layui-laypage-2" <c:if test="${pageInfo.pageNum eq null}">style="display: none" </c:if> >
                        <a href="${pageContext.request.contextPath}/lesson/toFindAllLessonPage/${pageInfo.prePage}/${pageInfo.pageSize}"
                           class="layui-laypage-prev" data-page="${pageInfo.prePage}" <c:if test="${!pageInfo.hasPreviousPage}">onclick="return false"</c:if> >上一页</a>
                        <c:forEach var="i" begin="${pageInfo.firstPage}" end="${pageInfo.lastPage}">
                            <c:if test="${i != pageInfo.pageNum}">
                                <a href="${pageContext.request.contextPath}/lesson/toFindAllLessonPage/${i}/${pageInfo.pageSize}" data-page="${i}">${i}</a>
                            </c:if>
                            <c:if test="${i == pageInfo.pageNum}">
                            <span class="layui-laypage-curr">
                                <em class="layui-laypage-em"></em><em>${i}</em>
                            </span>
                            </c:if>
                        </c:forEach>
                        <a href="${pageContext.request.contextPath}/lesson/toFindAllLessonPage/${pageInfo.nextPage}/${pageInfo.pageSize}"
                           class="layui-laypage-next" data-page="${pageInfo.nextPage}" <c:if test="${!pageInfo.hasNextPage}">onclick="return false"</c:if> >下一页</a>
                    </div>
                    
                </div>
            </div>
        </div>
    </div>
</div>
<script src="${pageContext.request.contextPath}/assets/layui.all.js"></script>
<script>
    let form = layui.form,
        layer = layui.layer;
    form.on("submit(submit-form)", function (data) {
        let field = data.field;
        //执行操作
        return false;
    });


</script>
</body>

</html>
